# Create your tasks here
from __future__ import absolute_import, unicode_literals
from todolist.celery import app
from django.core.mail import send_mail
from django.conf import settings
from utils import get_token
import datetime


# celery -A todolist worker -P eventlet -l INFO -c 5 -n worker@%n
@app.task(name='sendemail')
def sendmail(name, email, token):
    send_mail(
        '激活邮件',
        '请及时激活该账户',
        settings.EMAIL_HOST_USER,  # 从这个邮箱登录发送邮件到下面的列表中的邮箱
        [email],
        # '320822007@qq.com',
        fail_silently=False,
        html_message="<h2>这是一封激活邮件，请{}在5分钟内完成激活，否则当前用户即为失效<a href='http://127.0.0.1:8000/users/active?username={}&token={}' target='_blank'>点击即可激活该账号</a></h2>".format(name, name, token)
    )

